package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.common.AreaControlVO;
import com.jwsoft.manager.common.vo.eduNetsign.EduNetsignKeyVO;
import com.jwsoft.manager.common.vo.eduNetsign.EduNetsignQueryVO;
import com.jwsoft.manager.common.vo.eduNetsign.EduNetsignVO;
import com.jwsoft.manager.common.vo.individuation.NetsignSaveVO;
import com.jwsoft.manager.core.integration.EduNetsignIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 学校网签合同表网关
 *
 * @author wangtao
 * @since 2022-12-21
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "学校网签合同表", description = "学校网签合同表")
public class EduNetsignController {

    @Autowired
    public EduNetsignIntegration eduNetsignIntegration;

    @Operation(summary = "学校网签合同表分页查询",description = "学校网签合同表分页查询")
    @PostMapping(value = "/eduNetsign0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduNetsignVO>> getList(@RequestBody @Validated EduNetsignQueryVO vo) {
        return AppResponse.successData(eduNetsignIntegration.getList(vo));
    }

    @Operation(summary = "学校网签合同表根据主键查询详情",description = "学校网签合同表根据主键查询详情")
    @PostMapping(value = "/eduNetsign0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduNetsignVO> getById(@RequestBody @Validated EduNetsignKeyVO vo) {
        return AppResponse.successData(eduNetsignIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校网签合同表新增",description = "学校网签合同表新增")
    @PostMapping(value = "/eduNetsign0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduNetsignVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduNetsignVO vo) {
        return AppResponse.successData(eduNetsignIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校网签合同表修改",description = "学校网签合同表修改")
    @PostMapping(value = "/eduNetsign0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduNetsignVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduNetsignVO vo) {
        return AppResponse.successData(eduNetsignIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校网签合同表删除",description = "学校网签合同表删除")
    @PostMapping(value = "/eduNetsign0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduNetsignKeyVO vo) {
        eduNetsignIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "根据身份证获取网签信息并保存",description = "根据身份证获取网签信息并保存")
    @PostMapping(value = "/eduNetsign0007", produces = "application/json;charset=UTF-8")
    public AppResponse getNetsignAndSave(@RequestBody @Validated NetsignSaveVO vo) {
        return AppResponse.successData(eduNetsignIntegration.getNetsignAndSave(vo));
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "根据合同编号获取网签信息",description = "根据合同编号获取网签信息")
    @PostMapping(value = "/eduNetsign0013", produces = "application/json;charset=UTF-8")
    public AppResponse getNetsignAndSaveJh(@RequestBody @Validated NetsignSaveVO vo) {
        return AppResponse.successData(eduNetsignIntegration.getNetsignAndSaveJh(vo));
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "家长端获取网签信息并保存",description = "家长端获取网签信息并保存")
    @PostMapping(value = "/eduNetsign0008", produces = "application/json;charset=UTF-8")
    public AppResponse getAppNetsignAndSave(@RequestBody @Validated NetsignSaveVO vo) {
        return AppResponse.successData(eduNetsignIntegration.getAppNetsignAndSave(vo));
    }
    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "根据合同编号获取网签信息 家长端",description = "根据合同编号获取网签信息 家长端")
    @PostMapping(value = "/eduNetsign0012", produces = "application/json;charset=UTF-8")
    public AppResponse getAppNetsignAndSaveJh(@RequestBody @Validated NetsignSaveVO vo) {
        return AppResponse.successData(eduNetsignIntegration.getAppNetsignAndSaveJh(vo));
    }
    @Operation(summary = "家长端获取我的网签信息",description = "家长端获取我的网签信息")
    @PostMapping(value = "/eduNetsign0009", produces = "application/json;charset=UTF-8")
    public AppResponse<List<EduNetsignVO>> getAppNetsignList(@RequestBody @Validated AreaControlVO vo) {
        return AppResponse.successData(eduNetsignIntegration.getAppNetsignList(vo));
    }

    @Operation(summary = "管理员分页查询学校网签合同表信息",description = "管理员分页查询学校网签合同表信息")
    @PostMapping(value = "/eduNetsign0010", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduNetsignVO>> getListAdmin(@RequestBody @Validated EduNetsignQueryVO vo) {
        return AppResponse.successData(eduNetsignIntegration.getListAdmin(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "管理员网签合同表新增",description = "学校网签合同表新增")
    @PostMapping(value = "/eduNetsign0011", produces = "application/json;charset=UTF-8")
    public AppResponse<EduNetsignVO> addAdmin(@RequestBody @Validated(value = {Validators.Add.class}) EduNetsignVO vo) {
        return AppResponse.successData(eduNetsignIntegration.addAdmin(vo));
    }

}
